/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32l0xx_hal.h"
#include "stm32l0xx_ll_adc.h"
#include "stm32l0xx_ll_iwdg.h"
#include "stm32l0xx_ll_lpuart.h"
#include "stm32l0xx_ll_rcc.h"
#include "stm32l0xx_hal.h"
#include "stm32l0xx_ll_usart.h"
#include "stm32l0xx_ll_bus.h"
#include "stm32l0xx_ll_cortex.h"
#include "stm32l0xx_ll_system.h"
#include "stm32l0xx_ll_utils.h"
#include "stm32l0xx_ll_pwr.h"
#include "stm32l0xx_ll_gpio.h"
#include "stm32l0xx_ll_dma.h"

#include "stm32l0xx_ll_exti.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdbool.h>
#include <string.h>
#include "stream/chprintf.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
//#define NVIC_EncodePriority(a, b, c) c

#ifndef FALSE
#   define FALSE false
#endif

#ifndef TRUE
#   define TRUE true
#endif

#define snprintf chsnprintf

#ifdef __DEBUG__
#   define debug(fmt, args...) printf(fmt, ##args)
#   define vdebug(fmt, vargs)  vprintf(fmt, vargs)
#   define ON_DEBUG(foo) foo
#   define ON_RELEASE(foo)
#   define IDLE()
#else
#   define debug(...)
#   define vdebug(fmt, vargs)
#   define ON_DEBUG(foo)
#   define ON_RELEASE(foo) foo
#   define IDLE() __WFI()
#endif

#ifndef UNUSED
#define UNUSED(x) (void) x
#endif

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#define BIT_SET(reg, bit) (reg) |= (bit)
#define BIT_CLR(reg, bit) (reg) &= ~ (bit)
#define BITS_SET(reg, mask, bits) do{reg = (reg & (~(mask))) | (bits);}while(0)
#define BIT_MASK(n) (0x01 << (n))

#define _PORT(p, n) p
#define _PIN(p, n)  n
#define PORT(io) (_PORT io)
#define PIN(io)  (_PIN io)
/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
#define RTC_WAKEUP_INTERVAL 20
/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
